Skip to content

Improve inference by not considering thisless functions to be context-sensitive #62243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Aug 9, 2025

implements @RyanCavanaugh's suggestion from #47599 :

As a stopgap, consider an object literal method to not be context-sensitive if it doesn't reference this. I believe we already have code for this and it would fix another large class of surprises.

fixes #62204
fixes #60986
fixes #58630
fixes #57572
fixes #56067
fixes #55489
fixes #55124
fixes #53924
fixes #50258

@Copilot Copilot AI review requested due to automatic review settings August 9, 2025 19:05
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Aug 9, 2025
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Aug 9, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves TypeScript's type inference by making functions that don't reference this not context-sensitive. Previously, all object literal methods were considered context-sensitive, causing poor inference when type parameters depended on inferring from these methods first. The change helps TypeScript better infer types in common patterns involving object literals with functions.

Key Changes:

  • Modified hasContextSensitiveParameters to check for actual this usage rather than assuming all function-like declarations are context-sensitive
  • Updated binder to track this keyword usage with NodeFlags.ContainsThis flag
  • Extended context-sensitive checking to include yield expressions in generators

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/compiler/binder.ts Adds tracking of this keyword usage and sets ContainsThis flag on functions
src/compiler/checker.ts Updates context-sensitive checking to include yield expressions and generators
src/compiler/utilities.ts Modifies hasContextSensitiveParameters and forEachYieldExpression to support new logic
tests/cases/compiler/*.ts New test cases demonstrating improved inference for thisless functions
tests/baselines/reference/. Updated baselines showing improved type inference results

@@ -2889,14 +2894,13 @@ export function forEachYieldExpression(body: Block, visitor: (expr: YieldExpress
if (node.name && node.name.kind === SyntaxKind.ComputedPropertyName) {
// Note that we will not include methods/accessors of a class because they would require
// first descending into the class. This is by design.
traverse(node.name.expression);
return;
return traverse(node.name.expression);;
}
Copy link
Preview

Copilot AI Aug 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a double semicolon at the end of this line. Remove the extra semicolon.

Copilot uses AI. Check for mistakes.

// Reset all reachability check related flags on node (for incremental scenarios)
node.flags &= ~NodeFlags.ReachabilityAndEmitFlags;
// Reset flags (for incremental scenarios)
node.flags &= ~(NodeFlags.ReachabilityAndEmitFlags | NodeFlags.ContainsThis);
Copy link
Preview

Copilot AI Aug 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment above this line mentions 'Reset all reachability check related flags' but now it also resets ContainsThis. Consider updating the comment to reflect that other flags are also being reset.

Suggested change
node.flags &= ~(NodeFlags.ReachabilityAndEmitFlags | NodeFlags.ContainsThis);
// Reset reachability, emit, and ContainsThis flags (for incremental scenarios)
node.flags &= ~(NodeFlags.ReachabilityAndEmitFlags | NodeFlags.ContainsThis);

Copilot uses AI. Check for mistakes.

if (!(currentFlow.flags & FlowFlags.Unreachable) && containerFlags & ContainerFlags.IsFunctionLike && nodeIsPresent((node as FunctionLikeDeclaration | ClassStaticBlockDeclaration).body)) {
node.flags |= NodeFlags.HasImplicitReturn;
if (hasExplicitReturn) node.flags |= NodeFlags.HasExplicitReturn;
(node as FunctionLikeDeclaration | ClassStaticBlockDeclaration).endFlowNode = currentFlow;
}
if (seenThisKeyword) {
node.flags |= NodeFlags.ContainsThis;
Copy link
Preview

Copilot AI Aug 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's trailing whitespace at the end of this line. Remove the extra spaces.

Suggested change
node.flags |= NodeFlags.ContainsThis;
node.flags |= NodeFlags.ContainsThis;

Copilot uses AI. Check for mistakes.

@@ -3941,28 +3951,27 @@ export function getContainerFlags(node: Node): ContainerFlags {
// falls through
case SyntaxKind.Constructor:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.ClassStaticBlockDeclaration:
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike;
case SyntaxKind.MethodSignature:
case SyntaxKind.CallSignature:
case SyntaxKind.JSDocSignature:
case SyntaxKind.JSDocFunctionType:
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructSignature:
case SyntaxKind.ConstructorType:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type-level AST nodes had ContainerFlags.IsControlFlowContainer here. This was messing up some of the changes I made since it was interfering with the implemented seenThisKeyword tracking. I don't see why those would be considered control flow containers and there are no tests proving it was needed.

Other changes in this function are basically of the same kind - I just removed ContainerFlags.IsControlFlowContainer from the type-level nodes.

@@ -21146,7 +21147,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}

function isContextSensitiveFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean {
return hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node);
return hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node) || !!(getFunctionFlags(node) & FunctionFlags.Generator && node.body && forEachYieldExpression(node.body as Block, isContextSensitive));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously generators were always context-sensitive as they can't even be arrow functions. At times, they are truly context-sensitive in cases like:

declare function test(
  gen: () => Generator<(arg: number) => string, void, void>,
): void;

test(function* () {
  yield (arg) => String(arg);
});

So I had to add this extra forEachYieldExpression to cover for this

/** @internal */
export function forEachYieldExpression(body: Block, visitor: (expr: YieldExpression) => void): void {
export function forEachYieldExpression<T>(body: Block, visitor: (expr: YieldExpression) => T): T | undefined {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this basically changes this function to work in the same way as forEachReturnStatement defined above

@@ -68,8 +68,8 @@ declare var connect: Connect;
const myStoreConnect: Connect = function(
>myStoreConnect : Connect
> : ^^^^^^^
>function( mapStateToProps?: any, mapDispatchToProps?: any, mergeProps?: any, options: unknown = {},) { return connect( mapStateToProps, mapDispatchToProps, mergeProps, options, );} : <TStateProps, TOwnProps>(mapStateToProps?: any, mapDispatchToProps?: any, mergeProps?: any, options?: unknown) => InferableComponentEnhancerWithProps<TStateProps, Omit<P, Extract<keyof TStateProps, keyof P>> & TOwnProps>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this just changes the inferred type to match the type inferred from the equivalent arrow function with type parameters, it's purely a result of making a thisless function context-insensitive

@@ -117,8 +117,8 @@ export const Nothing2: Strategy<State> = strategy("Nothing", function*(state: St
export const Nothing3: Strategy<State> = strategy("Nothing", function* (state: State) {
>Nothing3 : Strategy<State>
> : ^^^^^^^^^^^^^^^
>strategy("Nothing", function* (state: State) { yield ; return state; // `return`/`TReturn` isn't supported by `strategy`, so this should error.}) : (a: State) => IterableIterator<State, void>
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>strategy("Nothing", function* (state: State) { yield ; return state; // `return`/`TReturn` isn't supported by `strategy`, so this should error.}) : (a: any) => IterableIterator<any, void>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly here, this is a result of inferSignatureInstantiationForOverloadFailure no longer skipping the generator function on the basis it's context-sensitive (inferSignatureInstantiationForOverloadFailure uses CheckMode.SkipContextSensitive)

@@ -271,16 +271,16 @@ let impl: I = {
},
}
impl.explicitVoid1 = function () { return 12; };
>impl.explicitVoid1 = function () { return 12; } : (this: void) => number
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those this parameters were not used by the assigned implementation - they were just auto-assigned to it based on the this parameter in the contextual signature

@jakebailey
Copy link
Member

@typescript-bot test it
@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 9, 2025

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
pack this ✅ Started ✅ Results
test top400 ✅ Started 👀 Results
user test this ✅ Started 👀 Results
run dt ✅ Started 👀 Results
perf test this faster ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 9, 2025

Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/165836/artifacts?artifactName=tgz&fileId=13B4C26B69BE38B41CF288EF1AA02FC1EA994BAF88B23E179E9D52E418EE347402&fileName=/typescript-6.0.0-insiders.20250809.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.

There were interesting changes:

Branch only errors:

Package: jqrangeslider
Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/jqrangeslider/jqrangeslider-tests.ts
  160:20  error  TypeScript@local compile error: 
Function expression, which lacks return-type annotation, implicitly has an 'any' return type  @definitelytyped/expect

✖ 1 problem (1 error, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:199:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:191:20)

You can check the log here.

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user tests with tsc comparing main and refs/pull/62243/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Git clone failed"

Otherwise...

Something interesting changed - please have a look.

Details

effect

tsconfig.json

tsconfig.build.json

@typescript-bot
Copy link
Collaborator

@jakebailey
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - node (v18.15.0, x64)
Errors 34 34 ~ ~ ~ p=1.000 n=6
Symbols 62,370 62,370 ~ ~ ~ p=1.000 n=6
Types 50,386 50,386 ~ ~ ~ p=1.000 n=6
Memory used 192,921k (± 0.01%) 194,706k (± 0.99%) ~ 192,783k 196,638k p=0.378 n=6
Parse Time 1.30s (± 0.94%) 1.31s (± 0.62%) ~ 1.29s 1.31s p=1.000 n=6
Bind Time 0.73s 0.73s ~ ~ ~ p=1.000 n=6
Check Time 9.74s (± 0.27%) 9.71s (± 0.31%) ~ 9.67s 9.76s p=0.107 n=6
Emit Time 2.73s (± 0.85%) 2.73s (± 0.98%) ~ 2.68s 2.76s p=0.737 n=6
Total Time 14.51s (± 0.26%) 14.48s (± 0.29%) ~ 14.41s 14.53s p=0.259 n=6
angular-1 - node (v18.15.0, x64)
Errors 56 56 ~ ~ ~ p=1.000 n=6
Symbols 948,914 948,687 -227 (- 0.02%) ~ ~ p=0.001 n=6
Types 410,884 410,829 -55 (- 0.01%) ~ ~ p=0.001 n=6
Memory used 1,226,420k (± 0.00%) 1,225,226k (± 0.01%) -1,194k (- 0.10%) 1,225,099k 1,225,315k p=0.005 n=6
Parse Time 6.51s (± 0.76%) 6.54s (± 0.75%) ~ 6.48s 6.61s p=0.295 n=6
Bind Time 1.87s (± 0.28%) 1.88s (± 0.22%) +0.01s (+ 0.44%) 1.88s 1.89s p=0.022 n=6
Check Time 32.02s (± 0.51%) 31.97s (± 0.26%) ~ 31.86s 32.07s p=0.298 n=6
Emit Time 14.67s (± 1.19%) 14.85s (± 0.47%) ~ 14.74s 14.92s p=0.092 n=6
Total Time 55.07s (± 0.48%) 55.24s (± 0.19%) ~ 55.06s 55.34s p=0.298 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,548,622 2,548,597 -25 (- 0.00%) ~ ~ p=0.001 n=6
Types 903,221 903,206 -15 (- 0.00%) ~ ~ p=0.001 n=6
Memory used 2,833,313k (± 0.00%) 2,832,160k (± 0.00%) -1,153k (- 0.04%) 2,832,066k 2,832,299k p=0.005 n=6
Parse Time 8.77s (± 0.32%) 8.77s (± 0.17%) ~ 8.74s 8.78s p=0.935 n=6
Bind Time 2.25s (± 0.61%) 2.26s (± 0.23%) ~ 2.25s 2.26s p=0.928 n=6
Check Time 85.83s (± 0.60%) 85.84s (± 0.52%) ~ 85.29s 86.48s p=0.936 n=6
Emit Time 2.32s (± 3.91%) 2.23s (± 9.27%) ~ 2.04s 2.48s p=0.574 n=6
Total Time 99.16s (± 0.53%) 99.10s (± 0.40%) ~ 98.38s 99.51s p=0.810 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,227,066 1,227,058 -8 (- 0.00%) ~ ~ p=0.001 n=6
Types 267,480 267,484 +4 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,363,039k (± 0.03%) 2,418,908k (± 6.14%) ~ 2,357,778k 2,722,466k p=0.066 n=6
Parse Time 5.19s (± 0.86%) 5.24s (± 0.93%) ~ 5.18s 5.31s p=0.128 n=6
Bind Time 1.78s (± 0.61%) 1.81s (± 0.73%) +0.03s (+ 1.59%) 1.79s 1.83s p=0.009 n=6
Check Time 35.41s (± 0.33%) 35.31s (± 0.64%) ~ 34.99s 35.64s p=0.471 n=6
Emit Time 2.99s (± 2.39%) 3.05s (± 2.72%) ~ 2.98s 3.21s p=0.149 n=6
Total Time 45.39s (± 0.43%) 45.41s (± 0.54%) ~ 45.11s 45.77s p=0.936 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,227,066 1,227,058 -8 (- 0.00%) ~ ~ p=0.001 n=6
Types 267,480 267,484 +4 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,824,370k (±13.26%) 2,940,432k (±11.52%) ~ 2,428,471k 3,157,631k p=0.575 n=6
Parse Time 6.83s (± 1.55%) 6.82s (± 1.38%) ~ 6.69s 6.90s p=0.521 n=6
Bind Time 2.18s (± 2.34%) 2.21s (± 1.13%) ~ 2.18s 2.25s p=0.148 n=6
Check Time 42.73s (± 0.81%) 42.93s (± 0.84%) ~ 42.21s 43.22s p=0.378 n=6
Emit Time 3.56s (± 1.53%) 3.58s (± 2.67%) ~ 3.44s 3.67s p=0.575 n=6
Total Time 55.30s (± 0.80%) 55.55s (± 0.83%) ~ 54.65s 55.98s p=0.471 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 262,555 262,559 +4 (+ 0.00%) ~ ~ p=0.001 n=6
Types 107,165 107,177 +12 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 441,956k (± 0.01%) 441,608k (± 0.01%) -348k (- 0.08%) 441,571k 441,667k p=0.005 n=6
Parse Time 4.38s (± 0.72%) 4.38s (± 0.64%) ~ 4.34s 4.42s p=0.935 n=6
Bind Time 1.62s (± 0.75%) 1.63s (± 1.19%) ~ 1.61s 1.66s p=0.868 n=6
Check Time 23.48s (± 0.23%) 23.49s (± 0.30%) ~ 23.41s 23.58s p=0.936 n=6
Emit Time 1.91s (± 0.97%) 1.91s (± 0.63%) ~ 1.89s 1.92s p=0.625 n=6
Total Time 31.39s (± 0.16%) 31.40s (± 0.19%) ~ 31.33s 31.48s p=0.810 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 71 71 ~ ~ ~ p=1.000 n=6
Symbols 225,367 225,367 ~ ~ ~ p=1.000 n=6
Types 94,290 94,290 ~ ~ ~ p=1.000 n=6
Memory used 371,100k (± 0.01%) 370,813k (± 0.02%) -287k (- 0.08%) 370,749k 370,919k p=0.005 n=6
Parse Time 2.89s (± 1.00%) 2.90s (± 1.36%) ~ 2.84s 2.94s p=0.573 n=6
Bind Time 1.59s (± 0.47%) 1.64s (± 1.76%) +0.04s (+ 2.72%) 1.60s 1.68s p=0.007 n=6
Check Time 16.45s (± 0.36%) 16.44s (± 0.33%) ~ 16.37s 16.51s p=0.689 n=6
Emit Time 0.00s (±244.70%) 0.00s ~ ~ ~ p=0.405 n=6
Total Time 20.93s (± 0.36%) 20.96s (± 0.34%) ~ 20.86s 21.05s p=0.520 n=6
vscode - node (v18.15.0, x64)
Errors 1 6 🔻+5 (+500.00%) ~ ~ p=0.001 n=6
Symbols 3,843,514 3,839,554 -3,960 (- 0.10%) ~ ~ p=0.001 n=6
Types 1,211,401 1,210,628 -773 (- 0.06%) ~ ~ p=0.001 n=6
Memory used 3,677,122k (± 0.00%) 3,674,086k (± 0.00%) -3,036k (- 0.08%) 3,673,905k 3,674,201k p=0.005 n=6
Parse Time 15.27s (± 0.69%) 15.30s (± 0.56%) ~ 15.20s 15.45s p=0.423 n=6
Bind Time 4.94s (± 0.50%) 5.04s (± 2.69%) ~ 4.95s 5.23s p=0.064 n=6
Check Time 101.40s (± 1.96%) 103.38s (± 3.10%) ~ 100.01s 109.50s p=0.230 n=6
Emit Time 34.63s (±26.92%) 32.00s (± 8.83%) ~ 30.52s 37.76s p=1.000 n=6
Total Time 156.24s (± 6.40%) 155.74s (± 2.41%) ~ 151.55s 160.88s p=0.297 n=6
webpack - node (v18.15.0, x64)
Errors 2 2 ~ ~ ~ p=1.000 n=6
Symbols 320,272 320,263 -9 (- 0.00%) ~ ~ p=0.001 n=6
Types 139,137 139,125 -12 (- 0.01%) ~ ~ p=0.001 n=6
Memory used 476,591k (± 0.03%) 476,019k (± 0.02%) -572k (- 0.12%) 475,920k 476,167k p=0.005 n=6
Parse Time 4.33s (± 0.45%) 4.34s (± 0.27%) ~ 4.33s 4.36s p=0.618 n=6
Bind Time 1.85s (± 0.95%) 1.84s (± 1.22%) ~ 1.82s 1.87s p=0.413 n=6
Check Time 21.10s (± 0.61%) 21.14s (± 0.28%) ~ 21.07s 21.21s p=0.521 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 27.27s (± 0.49%) 27.31s (± 0.28%) ~ 27.23s 27.42s p=0.520 n=6
xstate-main - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 663,630 663,455 -175 (- 0.03%) ~ ~ p=0.001 n=6
Types 198,311 198,165 -146 (- 0.07%) ~ ~ p=0.001 n=6
Memory used 570,537k (± 0.02%) 569,637k (± 0.03%) -900k (- 0.16%) 569,437k 569,810k p=0.005 n=6
Parse Time 4.28s (± 0.79%) 4.28s (± 0.65%) ~ 4.24s 4.32s p=1.000 n=6
Bind Time 1.33s (± 0.77%) 1.32s (± 0.88%) ~ 1.31s 1.34s p=0.117 n=6
Check Time 20.07s (± 1.90%) 20.21s (± 1.70%) ~ 19.87s 20.60s p=0.298 n=6
Emit Time 0.00s 0.00s (±244.70%) ~ 0.00s 0.01s p=0.405 n=6
Total Time 25.68s (± 1.56%) 25.81s (± 1.43%) ~ 25.46s 26.25s p=0.470 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top 400 repos with tsc comparing main and refs/pull/62243/merge:

Something interesting changed - please have a look.

Details

reduxjs/reselect

test/tsconfig.json

steven-tey/novel

1 of 2 projects failed to build with the old tsc and were ignored

packages/headless/tsconfig.json

ueberdosis/tiptap

3 of 8 projects failed to build with the old tsc and were ignored

tests/cypress/tsconfig.json

@Andarist
Copy link
Contributor Author

Andarist commented Aug 10, 2025

  1. jqrangeslider break - I'm not concerned about it. It already behaves quite weirdly today: TS playground
  2. novel break - this is an improvement. The current code only works because it infers any for the extension's options: TS playground. It's not great that using this in addOptions makes it to infer any again - but that's not a new problem.
  3. tiptap break - this is basically the same as above (the above uses tiptap). This code only works now because it infers any for the options: TS playground
  4. reselect break - this is just a moved error position (the new position matches the position reported when an arrow function is used instead of a function expression): TS playground. It's worth noting those were changed in tests that inentionally use invalid arguments to test that a runtime error is thrown when the function receives them
  5. effect break - this one is actually bad for their users: TS playground. Without this change they are able to benefit from the return type inference. With this change, they could benefit from it but some earlier inferences made from returnOnlyType prevent that. This type was never created before for generators as they were always considered to have a context-sensitive parameter.

@jakebailey
Copy link
Member

@typescript-bot test it
@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 11, 2025

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
pack this ✅ Started ✅ Results
test top400 ✅ Started
user test this ✅ Started 👀 Results
run dt ✅ Started 👀 Results
perf test this faster ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 11, 2025

Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/165850/artifacts?artifactName=tgz&fileId=8C27070A12055925406C680737D02B67824D8D3CFB34BD5BC89B4B93A679A97B02&fileName=/typescript-6.0.0-insiders.20250811.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.

There were interesting changes:

Branch only errors:

Package: jqrangeslider
Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/jqrangeslider/jqrangeslider-tests.ts
  160:20  error  TypeScript@local compile error: 
Function expression, which lacks return-type annotation, implicitly has an 'any' return type  @definitelytyped/expect

✖ 1 problem (1 error, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:199:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:191:20)

You can check the log here.

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user tests with tsc comparing main and refs/pull/62243/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Git clone failed"

Otherwise...

Something interesting changed - please have a look.

Details

effect

tsconfig.json

@typescript-bot
Copy link
Collaborator

@jakebailey
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - node (v18.15.0, x64)
Errors 34 34 ~ ~ ~ p=1.000 n=6
Symbols 62,370 62,370 ~ ~ ~ p=1.000 n=6
Types 50,386 50,386 ~ ~ ~ p=1.000 n=6
Memory used 193,582k (± 0.75%) 195,282k (± 0.96%) ~ 192,842k 196,642k p=0.689 n=6
Parse Time 1.30s (± 0.79%) 1.31s (± 0.64%) ~ 1.29s 1.31s p=0.923 n=6
Bind Time 0.73s 0.73s ~ ~ ~ p=1.000 n=6
Check Time 9.73s (± 0.12%) 9.69s (± 0.22%) -0.04s (- 0.41%) 9.66s 9.71s p=0.008 n=6
Emit Time 2.73s (± 0.36%) 2.74s (± 0.58%) ~ 2.71s 2.75s p=0.310 n=6
Total Time 14.49s (± 0.10%) 14.47s (± 0.14%) ~ 14.44s 14.50s p=0.052 n=6
angular-1 - node (v18.15.0, x64)
Errors 56 56 ~ ~ ~ p=1.000 n=6
Symbols 948,914 948,687 -227 (- 0.02%) ~ ~ p=0.001 n=6
Types 410,884 410,829 -55 (- 0.01%) ~ ~ p=0.001 n=6
Memory used 1,226,370k (± 0.00%) 1,225,226k (± 0.00%) -1,145k (- 0.09%) 1,225,196k 1,225,274k p=0.005 n=6
Parse Time 6.53s (± 0.64%) 6.49s (± 0.53%) ~ 6.44s 6.54s p=0.192 n=6
Bind Time 1.87s (± 0.28%) 1.89s (± 0.40%) +0.01s (+ 0.80%) 1.88s 1.90s p=0.010 n=6
Check Time 32.01s (± 0.20%) 31.92s (± 0.22%) -0.09s (- 0.28%) 31.82s 32.03s p=0.037 n=6
Emit Time 14.84s (± 0.70%) 14.85s (± 0.50%) ~ 14.76s 14.95s p=0.872 n=6
Total Time 55.25s (± 0.10%) 55.15s (± 0.20%) ~ 54.99s 55.26s p=0.126 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,545,613 2,545,588 -25 (- 0.00%) ~ ~ p=0.001 n=6
Types 902,462 902,447 -15 (- 0.00%) ~ ~ p=0.001 n=6
Memory used 2,829,716k (± 0.01%) 2,828,517k (± 0.00%) -1,199k (- 0.04%) 2,828,341k 2,828,645k p=0.005 n=6
Parse Time 8.73s (± 0.35%) 8.73s (± 0.35%) ~ 8.69s 8.77s p=0.936 n=6
Bind Time 2.23s (± 0.34%) 2.24s (± 0.85%) ~ 2.21s 2.27s p=0.196 n=6
Check Time 86.74s (± 1.42%) 85.96s (± 0.73%) ~ 85.40s 87.16s p=0.128 n=6
Emit Time 0.30s (± 1.35%) 0.93s (±104.33%) ~ 0.30s 2.18s p=0.213 n=6
Total Time 98.00s (± 1.24%) 97.86s (± 1.12%) ~ 96.70s 99.18s p=0.575 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,227,066 1,227,059 -7 (- 0.00%) ~ ~ p=0.001 n=6
Types 267,480 267,484 +4 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,853,943k (±13.22%) 2,727,226k (±14.66%) ~ 2,361,697k 3,093,505k p=0.066 n=6
Parse Time 6.64s (± 2.23%) 6.60s (± 1.38%) ~ 6.48s 6.71s p=0.575 n=6
Bind Time 2.17s (± 2.02%) 2.19s (± 0.94%) ~ 2.15s 2.21s p=0.747 n=6
Check Time 42.85s (± 0.31%) 42.78s (± 0.28%) ~ 42.65s 42.92s p=0.521 n=6
Emit Time 3.50s (± 2.77%) 3.52s (± 4.88%) ~ 3.23s 3.77s p=0.687 n=6
Total Time 55.16s (± 0.41%) 55.08s (± 0.48%) ~ 54.61s 55.31s p=0.936 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,227,066 1,227,059 -7 (- 0.00%) ~ ~ p=0.001 n=6
Types 267,480 267,484 +4 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,918,970k (±12.88%) 2,792,393k (±14.30%) ~ 2,427,003k 3,158,256k p=0.066 n=6
Parse Time 6.88s (± 1.31%) 6.80s (± 1.62%) ~ 6.66s 6.96s p=0.230 n=6
Bind Time 2.15s (± 1.99%) 2.21s (± 1.06%) +0.07s (+ 3.19%) 2.18s 2.24s p=0.030 n=6
Check Time 43.12s (± 0.47%) 42.69s (± 0.46%) -0.42s (- 0.99%) 42.47s 42.99s p=0.020 n=6
Emit Time 3.60s (± 3.10%) 3.53s (± 2.85%) ~ 3.43s 3.70s p=0.199 n=6
Total Time 55.74s (± 0.40%) 55.23s (± 0.42%) -0.50s (- 0.91%) 54.88s 55.49s p=0.013 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 262,555 262,560 +5 (+ 0.00%) ~ ~ p=0.001 n=6
Types 107,165 107,177 +12 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 441,784k (± 0.01%) 441,437k (± 0.02%) -347k (- 0.08%) 441,365k 441,574k p=0.005 n=6
Parse Time 2.89s (± 0.36%) 2.88s (± 0.61%) ~ 2.85s 2.90s p=0.323 n=6
Bind Time 1.11s 1.12s (± 0.36%) +0.01s (+ 1.05%) 1.12s 1.13s p=0.002 n=6
Check Time 15.83s (± 0.43%) 15.86s (± 0.33%) ~ 15.78s 15.92s p=0.467 n=6
Emit Time 1.29s (± 1.14%) 1.31s (± 0.79%) +0.02s (+ 1.68%) 1.30s 1.33s p=0.022 n=6
Total Time 21.13s (± 0.43%) 21.18s (± 0.21%) ~ 21.10s 21.22s p=0.226 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 71 71 ~ ~ ~ p=1.000 n=6
Symbols 225,367 225,367 ~ ~ ~ p=1.000 n=6
Types 94,290 94,290 ~ ~ ~ p=1.000 n=6
Memory used 371,247k (± 0.05%) 370,821k (± 0.03%) -425k (- 0.11%) 370,730k 371,010k p=0.005 n=6
Parse Time 3.58s (± 1.53%) 3.60s (± 0.78%) ~ 3.56s 3.64s p=0.467 n=6
Bind Time 1.99s (± 1.41%) 1.99s (± 1.04%) ~ 1.96s 2.01s p=0.805 n=6
Check Time 20.35s (± 0.41%) 20.32s (± 0.34%) ~ 20.23s 20.39s p=1.000 n=6
Emit Time 0.00s 0.00s (±244.70%) ~ 0.00s 0.01s p=0.405 n=6
Total Time 25.92s (± 0.49%) 25.92s (± 0.24%) ~ 25.83s 25.99s p=0.873 n=6
vscode - node (v18.15.0, x64)
Errors 1 6 🔻+5 (+500.00%) ~ ~ p=0.001 n=6
Symbols 3,844,939 3,840,979 -3,960 (- 0.10%) ~ ~ p=0.001 n=6
Types 1,212,130 1,211,357 -773 (- 0.06%) ~ ~ p=0.001 n=6
Memory used 3,679,289k (± 0.01%) 3,675,893k (± 0.00%) -3,396k (- 0.09%) 3,675,717k 3,676,055k p=0.005 n=6
Parse Time 15.30s (± 0.48%) 15.33s (± 0.64%) ~ 15.18s 15.42s p=0.630 n=6
Bind Time 4.96s (± 2.44%) 5.13s (± 3.24%) ~ 4.90s 5.27s p=0.053 n=6
Check Time 102.88s (± 2.36%) 100.83s (± 1.18%) ~ 100.08s 103.24s p=0.128 n=6
Emit Time 34.83s (±20.07%) 30.77s (± 0.78%) ~ 30.53s 31.15s p=0.199 n=6
Total Time 157.96s (± 3.89%) 152.06s (± 0.75%) 🟩-5.90s (- 3.74%) 151.28s 154.36s p=0.008 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 320,441 320,432 -9 (- 0.00%) ~ ~ p=0.001 n=6
Types 139,219 139,207 -12 (- 0.01%) ~ ~ p=0.001 n=6
Memory used 476,977k (± 0.03%) 476,312k (± 0.02%) -665k (- 0.14%) 476,202k 476,390k p=0.005 n=6
Parse Time 4.33s (± 0.75%) 4.33s (± 0.27%) ~ 4.32s 4.35s p=1.000 n=6
Bind Time 1.84s (± 1.31%) 1.83s (± 0.75%) ~ 1.80s 1.84s p=0.073 n=6
Check Time 21.10s (± 0.51%) 21.08s (± 0.44%) ~ 20.94s 21.23s p=0.809 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 27.27s (± 0.45%) 27.24s (± 0.36%) ~ 27.08s 27.39s p=1.000 n=6
xstate-main - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 663,768 663,593 -175 (- 0.03%) ~ ~ p=0.001 n=6
Types 198,416 198,270 -146 (- 0.07%) ~ ~ p=0.001 n=6
Memory used 570,743k (± 0.02%) 569,857k (± 0.02%) -886k (- 0.16%) 569,716k 569,983k p=0.005 n=6
Parse Time 4.29s (± 0.50%) 4.29s (± 0.27%) ~ 4.28s 4.31s p=1.000 n=6
Bind Time 1.34s (± 0.91%) 1.32s (± 0.92%) -0.02s (- 1.50%) 1.30s 1.33s p=0.021 n=6
Check Time 19.99s (± 1.66%) 20.12s (± 1.75%) ~ 19.84s 20.61s p=0.470 n=6
Emit Time 0.00s (±244.70%) 0.00s ~ ~ ~ p=0.405 n=6
Total Time 25.62s (± 1.32%) 25.73s (± 1.34%) ~ 25.45s 26.20s p=0.470 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment